home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4424 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question-2
  5. Date: 03 Feb 1996 18:06:34 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <TANMOY.96Feb3110634@qcd.lanl.gov>
  9. References: <4eur52$oaq@recepsen.aa.msen.com> <2FEB199622525027@erich.triumf.ca>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: bennett@erich.triumf.ca's message of 2 Feb 1996 22:52 PST
  14.  
  15. In article <2FEB199622525027@erich.triumf.ca> bennett@erich.triumf.ca
  16. (P.Bennett) writes: 
  17.    >What is the relationship between short, int and long variables?
  18.  
  19.    shorts are shorter than longs.  Ints may be the same as either, or not.
  20.  
  21. Actually, all three are allowed to be equal! But, typically, the above
  22. answer is correct: except that ints must be `between' short and long.
  23.  
  24. shorts and ints are guaranteed to be at least 16 bits (including the
  25. sign bit) and longs are guaranteed to be at least 32 bits. ints are
  26. expected to be the `natural' integer that the hardware supports: which
  27. means that they should be used whenever there is no reason to choose
  28. any particular type (it may mean for example that the code is faster
  29. or the instructions required to manipulate the data is shorter if ints
  30. are used.)
  31.  
  32. In addition, shorts, like chars, are promoted to ints in almost all
  33. calculations. Preprocessor arithmetic is done as longs.
  34.  
  35. Cheers
  36. Tanmoy
  37. --
  38. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  39. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  40. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  41. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  42. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  43. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  44.